<extend name="./public/frame.html"/>
<block name="content">
    <div class="layui-row">

        <div class="layui-col-xs6 layui-col-md2 layui-col-lg2">
            <div class="layui-form">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" style="width: 200px" placeholder="请输入订单号"  class="layui-input" id="order_sn">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-md2 layui-col-lg2">
            <div class="layui-btn-group">
                <button class="layui-btn" data-type="search">搜索</button>
                <button class="layui-btn layui-btn-disabled" data-type="" id="reset">复位</button>
            </div>
        </div>
    </div>
    <table class="layui-table" hidden id="query">

    </table>
    <script type="application/javascript">
        layui.use(['table', 'laytpl', 'laydate','form'], function () {
            var table = layui.table
                , form = layui.form
                , laydate = layui.laydate;
            lay('.date').each(function(){
                laydate.render({
                    elem: this
                    ,type: 'date'
                    ,trigger: 'click'
                });
            });

            var $ = layui.jquery, active = {
                search: function () {
                    var order_sn = $('#order_sn').val();
                    var info = $('#query');
                    var reset = $('#reset');
                    if(order_sn){
                        reset.removeClass('layui-btn-disabled').addClass('layui-btn-normal').data('type', 'reset');
                        $.post('/admin/inter_refund/query',{order_sn:order_sn},function (res) {
                            switch (res['status']){
                                case 1:
                                    info.html(res['data']).show();
                                    break;
                                default:
                                    layer.alert(res['msg'],{icon: 5},function (index) {
                                        info.html('').hide();
                                        layer.close(index);
                                    });
                                    break;
                            }
                        },'json')
                    }else{
                        reset.removeClass('layui-btn-normal').addClass('layui-btn-disabled').data('type', '');
                        layer.alert('订单号不能为空');
                    }
                }
                , reset: function () {
                    var reset = $('#reset');
                    var info = $('#query');
                    if (reset.data('type') !== '') {
                        info.html('').hide();
                    }
                    $('.layui-input').each(function () {                        $(this).val('');                    });                $('.layui-this').each(function () {$(this).removeClass('layui-this');});
                    reset.removeClass('layui-btn-normal').addClass('layui-btn-disabled').data('type', '');
                }
            };
            $('.layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });

    </script>
</block>
